package study.designpattern.observer;

import java.util.ArrayList;
import java.util.List;

public class PaperPublisher {
    private List registers = new ArrayList();
    
    public void regist(Subscriber subscriber){
        registers.add(subscriber);
    }
    
    public void unSubscribe(Subscriber subscriber){
        registers.remove(subscriber);
    }
    
    public void notifySubscribers(){
        for(int i=0; i< registers.size(); i++){
            Subscriber subscriber = (Subscriber) registers.get(i);
            subscriber.receive();
        }
    }
}
